<?php
ob_start();
session_start();
$_SESSION['page']="esa/home.php";
$id=$_SESSION['id'];

include_once('restconnection.php');

 if(isset($client)){

   
    //retrive base url 
    $url = $_SESSION['basic_url'];
    //add service url
    $service_url="/GetDataUser?";
    //params url
    $params = array('id'=>$id);
    //params connection
    $ctx = stream_context_create(array('http' => array('timeout' => 5))); 
    //send GET request
    $output = @file_get_contents($url.$service_url."id=".$params['id'],0,$ctx);
    //parse JSON output
    $data = json_decode($output);
    $data_user = $data->GetDataUserResult;
    
    //print_r($data_user); break;
    
    //GetDataUserInformation
    $name=$data_user[1];
    $logo=$data_user[0];
    
    $_SESSION['name']= $name;
    $_SESSION['logo']= $logo;
    
 
  
    //add service url
    $service_url_1="/GetServiceOn?";
    //send GET request
    $output = @file_get_contents($url.$service_url_1."id=".$params['id'],0,$ctx);
    //parse JSON output
    $data = json_decode($output);
    $get_access_token = $data->GetServiceOnResult;
    
    //print_r($get_access_token); break;

?>


<script type="text/javascript"> 
  ShowButtonSelect();
  ShowSocialPanel();
  ShowPostPanel();//show cross posting panel
  HidePostPanel();
  select_social_network();
  placeholderIE9();//show placeholder on IEexplorer
  CrossPosting('<?php echo$id ?>');//call method crossPosting
  init_shadowbox();
  
</script>

    <div id="imglogout" class=""><a onclick="if(confirm('Are you sure you want logout?')){ovv_mainother('esa/logout.php');}"><img src="esa/img/logout.png" title="logout" /></a></div>
    
    <div class="profile_section"> <!-- sezione con info del profilo e pubblicazione messaggio -->
        
       	    <span class="fl company_name">Hi! <?php echo$name; ?></span>
            <div id="optionmenu" class="fr">
        <a><img src="esa/img/refresh.png" onclick="refreshDivUpdatePosts(); refreshStats();" style="width: 20px" class="fl" alt="refresh" title="refresh"> </a>
        <a rel="shadowbox" href="esa/general_stats.php" > <img src="esa/img/stats.gif"  onclick=" " style="width: 20px" class="fl" alt="statistic" title="statistic"> </a>
    </div>
            <div class="clear"></div>
            
            <div class="avatar fl"><img onclick="ovv_mainother('esa/img_select.php?logo=<?php echo$logo; ?>');" title="Choose Image" alt="Choose Image" src="<?php echo$logo; ?>" /></div>
            <label for="textareapost" class="hidden" >What's happening?</label>
            <textarea id="textareapost" placeholder="What's happening?" class="new_message fl" name="" val1="ale"  cols="" rows=""></textarea>            
            
            <div class="clear"></div>
            
            <div id="update" class="hidden">             
                <select name="select_social_post" id="select_social_post">
                    
            <?php 
     
            if(($get_access_token[0]!= "")&&($get_access_token[2]!= "")) echo"<option value='all'>All</option>";
            if($get_access_token[0]!= "") echo"<option value='facebook'>Facebook</option>";
            //if($get_access_token[1]!= "") echo"<option value='google'>Google +</option>";
            if($get_access_token[2]!= "") echo"<option value='twitter'>Twitter</option>";

        
             ?>
                </select>
                <input type="button" value="Share" id="share"/>
                <div id="update_message" class="hidden"> </div>
            </div>    
        
    
    <div class="clear"></div>
    </div> <!-- fine info + pubblucaizone  -->
    
    <div class="nav_section"> <!-- sezione con tasti mention e home timeline + search -->
            <input onclick="send_data_timeline('home','');" style="background:darkcyan;" id="button_home" type="button" value="Home"/>
            <input onclick="send_data_timeline('mention','');" id="button_mention" type="button" value="Mention"/>
            <script>search();</script>
            <label for="search" class="hidden"  >Search...</label>
            <input class="search" placeholder="Search..." type="text" value="" id="search"/>
    </div> <!-- fine tasti + search -->

    <div class="social_section"> <!-- sezione social -->
            <?php 
     
            if($get_access_token[0]!= "") echo" <div class='facebookk img_social_active selected ' id='FB' alt='Facebook'  title='hide'   ><script  type='text/javascript'>AddHiddenSocial('facebook');</script></div>";
            if($get_access_token[1]!= "") echo" <div class='googlee img_social_active selected  '  id='GP' alt='Google' title='hide'     ><script  type='text/javascript'>AddHiddenSocial('google');</script></div>";
            if($get_access_token[2]!= "") echo" <div class='twitterr img_social_active selected ' id='TW' alt='Twitter' title='hide'    ><script  type='text/javascript'>AddHiddenSocial('twitter');</script></div>";
            if($get_access_token[3]!= "") echo" <div class='linkedinn img_social_active selected ' id='null' alt='Facebook' title='hide' ><script  type='text/javascript'>AddHiddenSocial('null');</script></div>";   
            if($get_access_token[4]!= "") echo" <div class='pinterestt img_social_active selected' id='null' alt='Facebook' title='hide' ><script  type='text/javascript'>AddHiddenSocial('null');</script></div>";
            if($get_access_token[5]!= "") echo" <div class='foursquaree img_social_active selected' id='null' alt='Facebook' title='hide' ><script  type='text/javascript'>AddHiddenSocial('null');</script></div>";
           
        
             ?>
        
            <div class="clear"></div>
    </div> <!-- fine social  -->
    <div class="clear"></div>
            <input type="hidden" value1="1Facebook1" value2="1Google1" value3="1Twitter1" type_page="home"  name="hidden_social" id="hidden_social" />
           
        
    
    <div class="spacer"></div>
    
    
   
    <script>send_data_timeline('home','');</script>
     
    <div class="scrolltimelines scroll-pane-arrows"> 
        
            <div id="timelines" class="timelines" > </div> 
       
    </div>
    <div class="spacer"></div>
    
    <div id="opensocial" class="opensocial"><input type="button"  title="Add Social Network" value="Show Add Social Network" name="send" id="send2" /> </div>
    <div class="clear"></div>
    <div id="othercontent" class="othercontent">  
        
        <div id="social" class="social-content" ></div>
                            
                             
    </div>
   
    <?php
    
 }else{
     ?>
     <label style="color:red;font-size:15px;">Sorry Connection Error!</label><br/>
     <label><a><element onclick=" var link='esa/login_page.php'; ovv_mainother(link);" > Click to continue </a></label>
 <?php
 }
    
   ?>